#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
查询操作
@author Created by Yani on 2019/02/28
"""
import pymssql
import pandas as pd

# cursor = DBUtils(host='172.16.10.17', user='DBbi', pwd='B,CpkfG&e4WCIYMg', db='Star_Main_READ').connect()
connect = pymssql.connect(host='172.16.10.17', user='DBbi', password='B,CpkfG&e4WCIYMg', database='Star_Main_READ', charset="utf8")
# cursor = connect.cursor()


sql = "SELECT sys.fn_cdc_map_lsn_to_time(__$start_lsn) as _lsn, * FROM cdc.dbo_Rental_TenantContract_CT"

sql_contract = "select id, CityId, RoomId, ContractNumber, bdate, edate, TerminalTime, Rental, charge, " \
               "OriginalContractId, RentalDiscount, ChargeDiscount, deposit, paymethod, FinancialWay, " \
               "ProductSettings from dbo.Rental_TenantContract"

# cursor.execute(sql)
# print(cursor.fetchall())

df = pd.read_sql(sql_contract, con=connect)

print(df.shape)
# print(df['_lsn'])

connect.close()
